package main

import (
	"fmt"
)

func main() {
	//存放3个学生信息，每个学生都有name和sex
	stusMap := make(map[int32]map[string]string, 3)

	stusMap[0] = make(map[string]string, 2)
	stusMap[0]["name"] = "路飞"
	stusMap[0]["sex"] = "男"

	stusMap[1] = make(map[string]string, 2)
	stusMap[1]["name"] = "乔巴"
	stusMap[1]["sex"] = "男"

	stusMap[2] = make(map[string]string, 2)
	stusMap[2]["name"] = "娜美"
	stusMap[2]["sex"] = "女"

	fmt.Println(stusMap)
	fmt.Println("第一个学生的姓名：")
	fmt.Println(stusMap[0]["name"])

	//遍历,由于map无序，因此没法保证一定先输出name再输出sex
	for key, val := range stusMap {
		fmt.Printf("学号：%v \n", key)
		for innerKey, innerVal := range val {
			fmt.Printf("\t %v : %v", innerKey, innerVal)
		}
		fmt.Println()
	}
}
